common={
	initCatalogueMagePage:function(){
		// 绑定dom对象
		this.obj = {
			searchText:$('#searchText'),
		};
		// 声明全局变量
		this.vars = {
			datatable:[],
		};
		this.creatTable();
		this.time();
		this.selectInputInit();
		this.btnEvent();
	},
	time:function(){
		$('.J-datepickerTime-range').datePicker({
			format: 'YYYY-MM-DD HH:mm',
			isRange: true
		});

	},
	tableEvent:function(id,data,columns,paginationShow){
		$('#' + id).bootstrapTable({
			method: 'get',
			cache: false,
			height: 420,
			pagination: paginationShow,
			pageSize: 10,
			pageNumber:1,
			showColumns: true,
			striped: true,
			columns: columns,
			data :data,
			onPageChange: function (size, number) {

			},
			formatNoMatches: function(){
				return '无符合条件的记录';
			}
		});
	},
	selectInputInit:function() { // 地区input级联选择
		jrequest.get("/api/assessMent/selectByArea",{}).then(res => {
			var data = res.data;
			data[0].code=1;
			$.each(data[0].cityAreaVOS,function(i,dom){
				data[0].cityAreaVOS[i].code=2;
				$.each(data[0].cityAreaVOS[i].cityAreaVOS,function(j,dom){
					data[0].cityAreaVOS[i].cityAreaVOS[j].code=3;
				})
			})
			this.creatMainRido("qrm-main",data,"cityAreaVOS","code");
		})
	},
	creatMainRido:function(id,attr,child,jibie){
		$(id).html("");
		var sttrdiv="";
		for(var i=0;i<3;i++){
			sttrdiv +="<div class='qrm-border"+(i+1)+"' style='display:none'>"+
				"<ul class='qrm-lev-"+(i+1)+" qrm-lev' id='qrm-border1'>"+
				"</ul>"+
				"</div>"
		};
		$(".qrm-main").html(sttrdiv);
		var str="";
		$("#qrm-border1").html("");
		var forTree = function(o){
			for(var i=0;i<o.length;i++){
				var urlstr = "";
				try{
					urlstr = "<li><span data-id='"+o[i]["id"]+"'>"+ o[i]["name"] +"</span><i class='qrm-arrow-right'></i><ul class='li-zi-"+o[i][jibie]+"' style='display: none'>";
					str += urlstr;
					if(o[i][child] != null){
						forTree(o[i][child]);
					}
					str += "</ul>";
				}catch(e){}
			}
			return str;
		};
		$("#qrm-border1").html(forTree(attr));
	},
	creatTable:function(){
		var self=this;
		for (var i = 0; i < 0; i++) {
			var num = Math.floor(Math.random() * 10);
			var tlat = 108.939621 + Math.random() * 10 - 5;
			var tlng = 34.343147 + Math.random() * 10 - 5;
			self.vars.datatable.push({
				"id": i+1,
				"type": num % 2 == 0 ? "1" : "0",
				"position": [tlat, tlng],
				"carPi": "陕A" + Math.floor(Math.random() * 89999 + 10000),
				"owner": "张三" + Math.floor(Math.random() * 89999 + 10000),
				"colorValue": Math.floor(Math.random() * 10) % 3,
				"hfsj":"2019-06-29 16:58:46",
				"tongdao":"已处理",
				"wenjian":Math.floor(Math.random() * 100) % 20+"km/h",
				"lshfsj":"2019-06-29 16:58:46",
				"lxsc":Math.floor(Math.random() * 1000) % 60+"分钟",
				"caozuo":"获取证据"
			})
		};
		var columnsOne = [
			{
				field: 'id',
				title: '序号'
			},
			{
				field: 'vehicleNo',
				title: '车牌号码',
				visible: false
			},
			{
				field: 'vehicleColor',
				title: '车牌颜色'
			},
			{
				field: 'fileSize',
				title: '文件大小',
			},
			{
				field: 'startTime',
				title: '回放开始时间',
			},
			{
				field: 'endTime',
				title: '回放结束时间',
			},
			{
				field: 'videoSize',
				title: '录像时长',
			},
			{
				field: 'caozuo',
				title: '操作',
			},
		];
		self.tableEvent("check_detail",self.vars.datatable,columnsOne,true);

	},
	btnEvent:function(){
		$(".j-search-btn .j-btn1").click(function(){
			$(".qrm-input-border input").val("");
			$(".j-search-row .item").eq(0).find("input").val("");
			$(".j-search-row .item").eq(0).find("input").attr("data-id","");
			$(".j-search-row .item").eq(1).find("input").val("");
			$(".j-search-row .item").eq(2).find("input").val("");
			$(".j-search-row .item").eq(3).find("input").val("");
			$('.rtable_input1').find("input").val("");
		})
	}
}

$(function(){
	common.initCatalogueMagePage();
});